app.controller("z-employeeInformation-c", [ '$scope','$rootScope','$z-http','$sce','z-employeeInformation-s','z-edit-menu-s','$filter',
		function($scope,$rootScope,$zhttp,$sce,Service,MenuService,$filter) {
		$scope.viewModel = {};
		$scope.viewModel.employeeInformation = {};	
		$scope.viewModel.schedulWeek = {};
		$scope.editModel = {};
        $scope.editModel.year=null;
        $scope.editModel.month=null;

		//查询页面名称
		MenuService.getMenuByUrl({url:'employeeInformation'},
		function(data){	
			$scope.viewModel.menuList=data;
		},function(error) {});
		
		// 加载
		$scope.viewModel.bindData = function(){
			$scope.viewModel.isLoading=true;
			//获取基本信息
			Service.getEmployeeById({},
			function(data){
				$scope.viewModel.employeeInformation.employeeNo = data.employeeNo;
				$scope.viewModel.employeeInformation.chineseName = data.chineseName;
				$scope.viewModel.employeeInformation.englishName = data.englishName;
				$scope.viewModel.employeeInformation.sex = data.sex;
				$scope.viewModel.employeeInformation.sexName = data.sexName;
				$scope.viewModel.employeeInformation.email = data.email;
				if(data.firstDate == null){
					$scope.viewModel.employeeInformation.firstDate = "";
				}else{
					$scope.viewModel.employeeInformation.firstDate =  $filter("date")(data.firstDate, "yyyy/MM/dd");
				}
				if(data.entryDate == null){
					$scope.viewModel.employeeInformation.entryDate = "";
				}else{
					$scope.viewModel.employeeInformation.entryDate = $filter("date")(data.entryDate, "yyyy/MM/dd");
				}
				if(data.annualLeaveDate == null){
					$scope.viewModel.employeeInformation.annualLeaveDate = "";
				}else{
					$scope.viewModel.employeeInformation.annualLeaveDate = $filter("date")(data.annualLeaveDate, "yyyy/MM/dd");
				}
				$scope.viewModel.employeeInformation.employeeType = data.employeeType;
				if(data.employeeType==1){
					$scope.viewModel.employeeInformation.employeeTypeName="正式";
				}else if(data.employeeType==2){
					$scope.viewModel.employeeInformation.employeeTypeName="协力";
				}else if(data.employeeType==3){
					$scope.viewModel.employeeInformation.employeeTypeName="兼职";
				}else if(data.employeeType==4){
					$scope.viewModel.employeeInformation.employeeTypeName="其他";
				}
				$scope.viewModel.employeeInformation.employeeCategory = data.employeeCategory;
				$scope.viewModel.employeeInformation.employeeCategoryName = data.employeeCategoryName;
				$scope.viewModel.employeeInformation.level = data.level;
				$scope.viewModel.employeeInformation.regionType = data.regionType;
				$scope.viewModel.employeeInformation.regionTypeName = data.regionTypeName;
				$scope.viewModel.employeeInformation.departmentName = data.departmentName;
				$scope.viewModel.employeeInformation.roleName = data.roleName;
				$scope.viewModel.employeeInformation.corporationName = data.corporationName;
				$scope.viewModel.employeeInformation.roleList = data.roleList;
				if(data.departmentFromDate == null){
					$scope.viewModel.employeeInformation.departmentFromDate = "";
				}else{
					$scope.viewModel.employeeInformation.entryDate = new Date(data.entryDate).getFullYear()+"/"+(new Date(data.entryDate).getMonth()+1)+"/"+new Date(data.entryDate).getDate();
					$scope.viewModel.employeeInformation.departmentFromDate = new Date(data.departmentFromDate).getFullYear()+"/"+(new Date(data.departmentFromDate).getMonth()+1)+"/"+new Date(data.departmentFromDate).getDate();

				}
				if(data.departmentThruDate == null){
					$scope.viewModel.employeeInformation.departmentThruDate = "";
				}else{
					$scope.viewModel.employeeInformation.entryDate = new Date(data.entryDate).getFullYear()+"/"+(new Date(data.entryDate).getMonth()+1)+"/"+new Date(data.entryDate).getDate();
					$scope.viewModel.employeeInformation.departmentThruDate = new Date(data.departmentThruDate).getFullYear()+"/"+(new Date(data.departmentThruDate).getMonth()+1)+"/"+new Date(data.departmentThruDate).getDate();

				}
				if(data.roleFromDate == null){
					$scope.viewModel.employeeInformation.roleFromDate = "";
				}else{
					$scope.viewModel.employeeInformation.roleFromDate = new Date(data.roleFromDate).getFullYear()+"/"+(new Date(data.roleFromDate).getMonth()+1)+"/"+new Date(data.roleFromDate).getDate();
				}
				if(data.roleThruDate == null){
					$scope.viewModel.employeeInformation.roleThruDate = "";
				}else{
					$scope.viewModel.employeeInformation.roleThruDate = new Date(data.roleThruDate).getFullYear()+"/"+(new Date(data.roleThruDate).getMonth()+1)+"/"+new Date(data.roleThruDate).getDate();
				}
				if(data.corporationFromDate == null){
					$scope.viewModel.employeeInformation.corporationFromDate = "";
				}else{
					$scope.viewModel.employeeInformation.corporationFromDate = new Date(data.corporationFromDate).getFullYear()+"/"+(new Date(data.corporationFromDate).getMonth()+1)+"/"+new Date(data.corporationFromDate).getDate();
				}
				if(data.corporationThruDate == null){
					$scope.viewModel.employeeInformation.corporationThruDate = "";
				}else{
					$scope.viewModel.employeeInformation.corporationThruDate = new Date(data.corporationThruDate).getFullYear()+"/"+(new Date(data.corporationThruDate).getMonth()+1)+"/"+new Date(data.entryDate).getDate();
				}
				
				for(var i=0;$scope.viewModel.employeeInformation.roleList.length>i;i++){
					if($scope.viewModel.employeeInformation.roleList[i].fromDate == null){
						$scope.viewModel.employeeInformation.roleList[i].fromDate = "";
					}else{
						$scope.viewModel.employeeInformation.roleList[i].fromDate = new Date($scope.viewModel.employeeInformation.roleList[i].fromDate).getFullYear()+"/"+(new Date($scope.viewModel.employeeInformation.roleList[i].fromDate).getMonth()+1)+"/"+new Date($scope.viewModel.employeeInformation.roleList[i].fromDate).getDate();
					}
					if($scope.viewModel.employeeInformation.roleList[i].thruDate == null){
						$scope.viewModel.employeeInformation.roleList[i].thruDate = "";
					}else{
						$scope.viewModel.employeeInformation.roleList[i].thruDate = new Date($scope.viewModel.employeeInformation.roleList[i].thruDate).getFullYear()+"/"+(new Date($scope.viewModel.employeeInformation.roleList[i].thruDate).getMonth()+1)+"/"+new Date($scope.viewModel.employeeInformation.roleList[i].thruDate).getDate();
					}
				}
				
				$scope.viewModel.isLoading=false;
			},function(error) {
				$scope.viewModel.isLoading=false;
			});
		};
		$scope.viewModel.bindData();
		

} ]);